﻿@{
    ViewBag.Title = "MenuList";
    Layout = "~/Views/Shared/_LayoutChild.cshtml";
}
@section head {
    @if (false) {<script src="~/Scripts/jquery-1.6.4-vsdoc.js" type="text/javascript"></script>}
    @Html.Partial("_JqGrid")
    <script language="javascript" type="text/javascript">
        var selectId = "";
        var gridId = "#tableId";
        $(document).ready(function () {
            loadBaseDicTree('/SystemManage/Menu/GetMenuTreeNode/', 'menu_id', 'meun_parentid', 'menu_name', true);
            funGridInit();
        });
        function zTreeOnClick(event, treeId, treeNode, clickFlag) {

        }
        function zTreeOnAsyncSuccess() {
        }

        function refreshTreeNode(type) {
            
        }

        function editUser(type, _menuid) {
            var _url = "";
            if (type == "add") {
                _url = "/SystemManage/Menu/Edit_Menu?id=&parentid=" + _menuid;
            }
            else
                _url = "/SystemManage/Menu/Edit_Menu?id=" + _menuid;
            parent.asyncbox.open({
                url: _url,
                data: '',
                title: type == "add" ? "新增" : "编辑",
                width: 520,
                height: 350,
                scroll: 'no',
                modal: true,
                btnsbar: parent.$.btn.OKCANCEL, //按钮栏配置请参考 “辅助函数” 中的 $.btn。
                callback: function (action) {
                    var t = this;
                    if (action == 'ok') {
                        DialogFrame($(this).attr("id")).Save(t);
                        return false;
                    }
                    if (action == 'cancel') {

                    }
                    if (action == 'close') {

                    }
                }
            });
        }
        function Search() {
            //查询
            $(gridId).setGridParam({ page: 1 });
            $(gridId).trigger("reloadGrid");
        }
        function funGridInit() {
            //初始化表格
            var option = {
                height: $("#divGridContainer").height() - 51,
                width: $("#divGridContainer").width() - 2,
                url: '@Url.Content("~/SystemManage/Menu/GetMenuList")',
                autowidth: false,
                datatype: "json",
                sortname: 'Menu_ID',
                sortorder: 'asc',
                colModel: [
                { label: '菜单名称', name: 'Menu_NAME', width: 160 },
                { label: '菜单路径', name: 'Menu_Url', width: 300 },
                { hidden: true, name: 'Menu_ID' }
   	            ],
                onSelectRow: function (rowid, cellname, value, iRow, iCol) {
                },
                ondblClickRow: function (rowid) {
                    var _menuid = $(gridId).getCell(rowid, 'Menu_ID');
                    editUser("edit", _menuid);
                },
                beforeRequest: function (d) {
                    
                },
                gridComplete: function () {

                }
            }
            var o = jqGridHelper.getConfig("#pageId", option);
            $(gridId).jqGrid(o);
        }

        function funEditMenu() {
            var _menuid = jqGridHelper.getSelRowData(gridId, 'Menu_ID');
            if (_menuid != null) {
                editUser("edit", _menuid);
            }
        }
    </script>
}
<!--头部导航,不用时可以去掉-->
<div class="ui-layout-north">
    <div id="headertitle">
    </div>
    <div class="buttonlist" style="float: right; height: 34px; line-height: 36px; margin-right: 20px;">
        <a onclick="editNode('add')" class="button green"><span class="icon-botton" style="background: url('/Content/16/add.png') no-repeat scroll 0px 4px;">
        </span>新增</a> <a onclick="funEditMenu()" class="button green"><span class="icon-botton"
            style="background: url('/Content/16/edit.png') no-repeat scroll 0px 4px;"></span>
            编辑</a> <a onclick="deleteNode()" class="button green"><span class="icon-botton" style="background: url('/Content/16/delete.png') no-repeat scroll 0px 4px;">
            </span>删除</a>
    </div>
</div>
<!--左侧导航，不用时直接去掉-->
<div class="ui-layout-west">
    @Html.Partial("_BaseDicTree")
</div>
<!--主窗体，页面都需要的div-->
<div id="divGridContainer" class="ui-layout-center" style="overflow: auto;">
    <table id="tableId">
    </table>
    <div id="pageId">
    </div>
</div>
